/*************************************************************************
    > File Name: 1.htonl.c
    > Author: Ykk
    > Mail: 3393579535@qq.com 
    > Created Time: 2023年05月14日 星期日 22时02分40秒
 ************************************************************************/

#include<stdio.h>
#include<stdlib.h>
#include<arpa/inet.h>
#include<string.h>

int main(int argc,char *argv[])
{
	unsigned char buf[4]={192,168,1,2};
	unsigned int num = *(int *)buf;
	unsigned int sum = htonl(num);
	unsigned char *p = &sum;
	printf("%d,%d,%d,%d\n",*p,*(p+1),*(p+2),*(p+3));

	unsigned short a = 0X1234;
	unsigned short b = htons(a);
	printf("%x\n",b);
	return 0;
}
